﻿using System.IO;
using XLua;
using UnityEngine;
using System;

public class LuaManager : SingletonManager<LuaManager>
{
    private LuaEnv luaenv = null;

    public void Start()
    {
        luaenv = new LuaEnv();
        luaenv.AddLoader((ref string filename) =>
        {
            return ResManager.Instance.LoadLuaBytes(filename);
        });
        luaenv.DoString("require('Main').Start()");
    }

    public void Update()
    {
        if (luaenv != null)
        {
            luaenv.Tick();
        }
    }

    public void OnDestroy()
    {
        if (luaenv != null)
        {
            luaenv.Dispose();
            luaenv = null;
        }
    }



}